package com.example.homemodule.view.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.core.widget.NestedScrollView;

import com.example.homemodule.viewmodel.HomeViewModel;
import com.yilijk.base.utils.ALog;

public class DrugsNestedScrollView extends NestedScrollView {
    public DrugsNestedScrollView(@NonNull Context context) {
        super(context);
    }

    public DrugsNestedScrollView(@NonNull Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DrugsNestedScrollView(@NonNull Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        ALog.e("oakkk", "child intercept touch event: " + ev.getAction());

        return super.onInterceptTouchEvent(ev);
//        return true;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        ALog.e("oakkk", "child dispatch touch event: " + ev.getAction());
        if (HomeViewModel.isDrugsTlFixed) {
//            getParent().requestDisallowInterceptTouchEvent(true);
        } else {
            getParent().requestDisallowInterceptTouchEvent(false);
//            return false;
        }
        return super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        ALog.e("oakkk", "child on touch event: " + ev.getAction());

        return super.onTouchEvent(ev);

    }


}
